package com.example.netty.service.communication;

import com.example.netty.common.FluxQuery;
import com.example.netty.pojo.Communication;
import com.influxdb.client.InfluxDBClient;
import com.influxdb.client.WriteApiBlocking;
import com.influxdb.client.domain.WritePrecision;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CommunicationServiceImpl {
    @Autowired
    InfluxDBClient influxDBClient;

    public void isAdd(String bucketName){
        Communication communication=new Communication();
        communication.setState("state");
        WriteApiBlocking writeApiBlocking = influxDBClient.getWriteApiBlocking();
        FluxQuery.add(bucketName,writeApiBlocking,communication);
    }

    public boolean last(String bucketName, String second){
        return FluxQuery.newFindOne(influxDBClient,bucketName,second,"Communication", Communication.class)==null?true:false;
    }

}
